package com.mac.hosp_pre.admin.controller;

import com.mac.hosp_pre.admin.service.HospitalService;
import com.mac.hosp_pre.admin.model.req.HospitalQueryReqDto;
import com.mac.hosp_pre.admin.model.resp.HospitalRespDto;
import com.mac.hosp_pre.reply.PageResult;
import com.mac.hosp_pre.reply.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springdoc.api.annotations.ParameterObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "医院管理接口")
@RestController
@RequestMapping("/admin/hosp/hospital")
public class HospitalController {

    @Autowired
    private HospitalService hospitalService;

    @Operation(summary = "医院列表(条件查询分页)")
    @GetMapping("queryPage")
    public R queryPage(@ParameterObject HospitalQueryReqDto hospitalQuery) {
        PageResult<HospitalRespDto> pageResult = hospitalService.selectHospPage(hospitalQuery);
        return R.success(pageResult);
    }

    @Operation(summary = "更新医院上线状态")
    @Parameters({
            @Parameter(name = "id", description = "医院编号", required = true, in = ParameterIn.PATH),
            @Parameter(name = "status", description = "状态", required = true, in = ParameterIn.PATH)
    })
    @GetMapping("updateStatus/{id}/{status}")
    public R updateHospStatus(@PathVariable String id,@PathVariable Integer status) {
        hospitalService.updateStatus(id,status);
        return R.success();
    }

    @Operation(summary = "医院详情信息")
    @Parameter(name = "id",description = "医院编号", in = ParameterIn.PATH)
    @GetMapping("showDetail/{id}")
    public R showHospDetail(@PathVariable String id) {
        HospitalRespDto respDto = hospitalService.getHospById(id);
        return R.success(respDto);
    }
}
